from django.urls import path
from . import views
from django.conf.urls import url, include
from rest_framework import routers
from rest_framework_jwt.views import obtain_jwt_token, refresh_jwt_token

# 创建路由器并注册我们的视图。
router = routers.DefaultRouter()
router.register(r'albums', views.AlbumViewSet)
router.register(r'users', views.UserViewSet)
router.register(r'pictures', views.PictureViewSet)
# router.register(r'userinfo', views.UserView.as_view())


# API URL现在由路由器自动确定。
# 另外，我们还要包含可浏览的API的登录URL。
app_name = 'Photography'
urlpatterns = [
    path('', views.index, name='index_page'),
    path("user/", views.user, name='user'),
    path("reset/", views.reset, name='reset'),
    path("login/", views.login, name='admin'),
    url(r'api/v1/', include(router.urls)),
    # url(r'^api-auth/', include('rest_framework.urls', namespace='rest_framework')),
    url(r'^login/$', views.LoginViewSet.as_view()),
    path('home/', views.home, name='index_page'),
    # url(r"^api-token-auth/", views.obtain_auth_token),  # DRF 自带的 token 认证模式；需导入
    url(r"^jwt-login/", obtain_jwt_token),  # jwt的认证接口（路径可自定义任意命名）
    url(r'^api-token-refresh/', refresh_jwt_token),
    url(r'^userinfo/', views.UserView.as_view()),
    url(r'^upload/', views.UploadFile.as_view()),
    path('dashboard/', views.dashboard, name='dashboard'),
    url(r'^picture/by_albumid/$', views.PictureView.as_view()),
    # url(r'^albums/$', views.AlbumList.as_view()),
    # url(r'^albums/(?P<pk>[0-9]+)/$', views.AlbumDetail.as_view()),

]

